#include <workflow/Workflow.h>
#include <workflow/WFFacilities.h>
#include <workflow/WFTaskFactory.h>
#include <workflow/HttpUtil.h>
#include <workflow/WFHttpServer.h>
#include <unistd.h>
#include <signal.h>
#include <ctime>
#include <iostream>
#include <vector>

using std::cerr;
using std::cout;
using std::string;
using std::vector;

// 定义全局变量
static WFFacilities::WaitGroup waitGroup(1);

void signalhandler(int signum)
{
    waitGroup.done(); // 每done一次，等待的n就-1
}

void process(WFHttpTask * serverTask){//设计一个process
    // cout << "process\n";
}

int main()
{
    signal(SIGINT, signalhandler);

    WFHttpServer server(process); //根据process创建了一个server

    if (server.start(1234) == 0){ // 开启监听
        waitGroup.wait();
        cout << "finished!\n";
        server.stop();
    } else {
        perror("server start");
        return -1;
    }
}